﻿@model IEnumerable<tutors_clus.Models.message>
@using tutors_clus.Models;
@{
    ViewBag.Title = "Chi tiết tin nhắn";
    Layout = "~/Views/Shared/_Layout_Private.cshtml";
}
<div id="cleft">
    <div class="menu_private">
        <h3>@Model.Select(m=>m.course.name_cou).FirstOrDefault()</h3>
    <ul>
        <li>@Html.ActionLink("Mục thảo luận", "Comment_Of_Course", new { id_course=@Model.Select(m=>m.id_cou).FirstOrDefault()})</li>
        <li>@Html.ActionLink("Tin nhắn","Message_Of_Course", new { id_course=@Model.Select(m=>m.id_cou).FirstOrDefault()})</li>
    </ul>
</div>
    
</div>
<div id="cright">
    <div class="post">
        <div class="postbody">
            @foreach (var item in Model)
            {
                <div class="postbodytop">
                    <h1>@item.title_mes</h1>
                    <div class="infoAuthor"><span>
                        @{
                            if(@item.isrepply == true)
                            {
                                if (@item.course.teacher.id_tea == WebSecurity.CurrentUserId)
                                {
                                    <i>Bạn</i>
                                }
                                else
                                {
                                    @item.course.teacher.fullname_tea
                                }
                                
                            }else
                            {
                                @item.student.fullname_stu
                                
                            }
                        }
                 </span> đã đăng vào @item.createdate_msg</div>
                </div>
                <div class="postcontent">@MvcHtmlString.Create(item.content_mes)
                    
                </div>
            }
        </div>
        <div class="repost">
            
                    <div class="count_com">
                        <p>@ViewBag.count bình luận</p>
                    </div>
                    <hr />
                    @foreach (var item2 in ViewBag.detail_mes)
                    {
                        <div class="repostbody">
                        <div class="infoAuthor"><span>
                           @{
                            if(@item2.isrepply == true)
                            {
                                if (@item2.course.teacher.id_tea == WebSecurity.CurrentUserId)
                                {
                                    <i>Bạn</i>
                                }
                                else
                                {
                                    @item2.course.teacher.fullname_tea
                                }
                                
                            }else
                            {
                                @item2.student.fullname_stu
                                
                            }
                        }
                        </span> đã đăng vào @item2.createdate_msg</div>
                    
                        <div class="postcontent">@MvcHtmlString.Create(item2.content_mes)
                             <ul style="list-style:decimal;margin-left: 15px;">
                                @foreach (var item3 in @item2.message_file)
	                       {
                               int temp = @item3.id_att;
                               tutors_clubContext db = new tutors_clubContext();
                               var a = db.file_attach.Where(m => m.id_att == temp).FirstOrDefault();
                               <li style="float:left;list-style:decimal;padding-right:30px">
                               <a href="@a.source">@a.name</a>
                               </li>
	                        }
                           </ul>
                        </div>
                    </div>  
                    }
                
                
        </div>
            
        <div class="repost">
            <div class="count_com">
                <p>Bình luận mới</p>
            </div>
            <hr />
            <div class="repostbody">
                @using (Html.BeginForm("Reply_msg", "Teacher", new { id_cou = Model.Select(m => m.id_cou).FirstOrDefault(), id_msg = Model.Select(m => m.id_mes).FirstOrDefault() }, FormMethod.Post, new { @encType = "multipart/form-data" }))
                    {
                        <textarea id="contentCom" name="contentMsg" placeholder="Nội dung tin nhắn" ></textarea>
                        <br />
                        <input type="file" multiple="" name="fileuploads" value="" />
                        <input type="submit" name="name" value="Bình luận" />
                    }
            </div>
        </div>
    </div>
</div>